<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<title><?php echo $data['add'] ? 'FAQ添加' : 'FAQ修改'?></title>

<?php include VIEWS.'admin/style.html'?>

<script type="text/javascript">
<!--
function open_attr() {$('attr_detail','attr_titleopen').invoke('show);$('attr_titleclose').hide()}
function close_attr() {$('attr_detail','attr_titleopen').invoke('hide');$('attr_titleclose').show()}
<?php if($data['cols']):?>window.onload=open_attr;<?php endif;?>
//-->
</script>

<?php include VIEWS.'ajax.js.html'?>

<script language="JavaScript">
<!--
var aa = ajaxStart('post');
var timer = null;

function faq_update() {
    $('submit').disabled = true;
    var f = $('updateform');
    aa.call('faqsedit.php?id=<?php echo $data["id"]?>', 'ajaxadminEdit', faqupdate_result, $('updateform').serialize());
    return false;
}

function faqupdate_result(result) {
    var i;
    var d = $('updatemsg');
    try {
        i = (result.result[0].data == 1 ? '更新成功' : '<font color=FFFF66>更新失败</font>，请检查您填写的资料完整性后再提交');
    } catch(e) {
        i = '服务器错误，请稍候再试';
        d.style.backgroundColor= '#FF99FF';
    }

    $('submit').disabled = false;
    d.innerHTML = '&nbsp;&nbsp;&nbsp;' + i + '……';
    d.show();
    new Effect.Round('div', 'updatemsg');
    location.href="#top";
    if (timer) window.clearTimeout(timer);
    timer = window.setTimeout( "$('updatemsg').hide()", 10000);
}

//-->
</script>

</head>

<body class="admin-body">

<a name="top"></a>
<h1><?php echo $data['add'] ? 'FAQ添加' : 'FAQ修改'?></h1>

<div id="body">

<b>FAQ</b>：<a href="faqs.php">FAQ列表</a> - <a href="faqsedit.php?add=1">新增FAQ</a>

<br />

<br />
<div class="updatemsg" id="updatemsg" style="font-weight:bold;background-color:#FFCC66;font-size:12px;width:80%;display:none;">&nbsp;</div>
<form action="" method="post" id="updateform"><table width="70%"><tr><td>

<h2>问题</h2><br />
<input type="text" name="q" size="90" value="<?php echo $data['q']?>" />
<br /><br />

<h2>回答 - 必填</h2><br />

<?php
include ROOT.'scripts'.DS.'FCKeditor'.DS.'fckeditor.php';
$oFCKeditor = new FCKeditor('a') ;
$oFCKeditor->ToolbarSet = 'Basic';
$oFCKeditor->Height = 300;
$oFCKeditor->BasePath = '/scripts/FCKeditor/';
$oFCKeditor->Value = $data['a'] ;
$oFCKeditor->Create() ;
?>

<h2>其它</h2><br />
<b>浏览数：</b><input type="text" name="views" size="1" value="<?php echo $data['views']?>">
<br /><br /><br />

<p><input type="submit" value="更新FAQ" style="font-weight:bold" id="submit">&nbsp;<input type="reset" value="重置" style="font-weight:bold">
</form>

<?php if(!$data['add']):?><script>$('updateform').observe('submit', faq_update)</script><?php endif?>

<?php include VIEWS.'admin/runtime.html'?>

</div>

</body>
</html>
